# Contributor: George Hopkins <george-hopkins@null.net>
# Maintainer: George Hopkins <george-hopkins@null.net>
pkgname=mjpg-streamer
pkgver=0_git20210220
pkgrel=1
_commit="310b29f4a94c46652b20c4b7b6e5cf24e532af39"
pkgdesc="MJPEG streaming application for Linux-UVC compatible webcams"
url="https://github.com/jacksonliam/mjpg-streamer"
arch="all"
license="GPL-2.0-only"
makedepends="cmake jpeg-dev libgphoto2-dev linux-headers protobuf-c-dev sdl12-compat-dev zeromq-dev"
options="!check" # no test suite
source="
	$pkgname-$_commit.tar.gz::https://github.com/jacksonliam/mjpg-streamer/archive/$_commit.tar.gz
	version.patch
	"
builddir="$srcdir/$pkgname-$_commit/mjpg-streamer-experimental"

case "$CARCH" in
	armv7|armhf)
		makedepends="$makedepends raspberrypi-dev"
		subpackages="$subpackages $pkgname-input-raspicam:raspicam"
		;;
esac

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DGIT_HASH="$_commit" \
		$CMAKE_CROSSOPTS .
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

raspicam() {
	pkgdesc="$pkgdesc (Raspberry Pi camera input)"
	mkdir -p "$subpkgdir"/usr/lib/mjpg-streamer
	mv "$pkgdir"/usr/lib/mjpg-streamer/input_raspicam.so "$subpkgdir"/usr/lib/mjpg-streamer/
}

sha512sums="
e345390a930f51094760b19eccc0f8867ea0693a887669c230f1e9a9af0d38c745548f80896cb0b57c0741647e90384007fa3abdd6eecf9bed96555ae9465900  mjpg-streamer-310b29f4a94c46652b20c4b7b6e5cf24e532af39.tar.gz
9939f72c5336b801b3efb1ada353b343ef16050ea4600851b48766bc3365016632d79aeafd6e73422dce5d9836946770ff85dbc347986c9a98e6819e45bbd23b  version.patch
"
